//在一个对象中绑定函数，称为这个对象的方法
//方法必须用obj.xxx()的形式调用！
var xiaoming = {
    name: '小明',
    birth: 1990,
    age: function () 
    {
        var y = new Date().getFullYear();
        return y - this.birth;
    }
};

xiaoming.age; // function xiaoming.age()
xiaoming.age(); // 今年调用是25,明年调用就变成26了

var fn = xiaoming.age;
fn(); // Uncaught 


var xiaoming = {
    name: '小明',
    birth: 1990,
    age: function () {
        function getAgeFromBirth() {
            var y = new Date().getFullYear();
            return y - this.birth;
        }
        return getAgeFromBirth();
    }
};

xiaoming.age(); // NaN  